#-*- coding: utf-8 -*-
#@File      :计算各种图形的面积，周长 
#@Author    :liaogan
#@Datetime  :2022/4/17 22:23

# 实现正方形、长方形、圆形、三角形的面积和周长的计算，类
class Aare():
    def __init__(self,long,wide):
        self.long=long
        self.wide=wide

    def area(self):
        res=self.long*self.wide
        print(f'图形面积为{res}')
        return res

    def perimeter(self):
        res=2*(self.long+self.wide)
        print(f'图形的周长为{res}')
        return res

#正方形
class A_square(Aare):
    def area(self):
        res=super(A_square,self).area()
        print(f'正方形面积为{res}')
    # pass




#长方形
class A_rectangle(Aare):
    def area(self):
        res=super(A_rectangle,self).area()
        print( f'长方形的面积为{res}' )


    def perimeter(self):
        res=super(A_rectangle,self).perimeter()
        print( f'长方形的周长为{res}' )

#圆
class circular(Aare):
    def __init__(self,π,r):
        self.π=π
        self.r=r

    def area(self):
        res = self.π*self.r*self.r
        print( f'圆形的面积为{res}' )
        return res

    def perimeter(self):
        res=2*self.π*self.r
        print( f'圆形的周长为{res}' )
        return res
#三角形
class triangle(Aare):
    def __init__(self,long,wide,higt,bottom):
        super(triangle, self).__init__(long,wide)
        self.higt=higt
        self.bottom=bottom

    def area(self):#面积
        res = self.bottom * self.higt/2
        print( f'三角形的面积为{res}' )
        return res

    def perimeter(self):#周长
        res=self.long+self.wide+self.bottom
        print( f'三角形的周长为{res}')
        return res
if __name__ == '__main__':
    #正方形
    A=A_square(3,3)
    A.area()
    A.perimeter()

    # print( '-------------------\n' )
    # #长方形
    # B=A_rectangle(2,2)
    # B.area()
    # B.perimeter()
    # print( '-------------------\n' )
    # #圆形
    # C=circular(3.14,10)
    # C.area()
    # C.perimeter()
    # print( '-------------------\n' )
    # #三角形
    # D=triangle(3,4,5,3.5)
    # D.area()
    # D.perimeter()



